package com.lanou.horo.zhuizhui.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.android.volley.RequestQueue;
import com.lanou.horo.zhuizhui.adapter.CommunityPageTitleAdapter;
import com.lanou.horo.zhuizhui.R;

public class CommunityPageFragment extends Fragment {
    private RequestQueue queue;
    private TabLayout tabLayout;
    private ViewPager viewPager;

    @Override
    @Nullable
    public View onCreateView(LayoutInflater inflater,
                             @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        View view = inflater.inflate(R.layout.fragment_community_page, null);

        tabLayout = (TabLayout) view.findViewById(R.id.communityTabLayout);
        viewPager = (ViewPager) view.findViewById(R.id.communityViewPager);

        return view;
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onActivityCreated(savedInstanceState);

        initData();
    }

    private void initData() {
        CommunityPageTitleAdapter adapter = new CommunityPageTitleAdapter(getFragmentManager());
        viewPager.setAdapter(adapter);
        // TabLayout和Viewpager进行绑定
        tabLayout.setupWithViewPager(viewPager);

//        //遍历tab进行设置
//        for (int i = 0; i <tabLayout.getTabCount() ; i++) {
//            tabLayout.getTabAt(i).setIcon(R.mipmap.ic_launcher);
//        }

    }
}